<template>
  <div class="app-container">
    <!--表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="日期">
        <el-date-picker v-model="day" type="date" placeholder="选择要统计的日期" value-format="yyyy-MM-dd" />
      </el-form-item>
      <el-button :disabled="btnDisabled" type="primary" @click="create()">生成</el-button>
    </el-form>
  </div>
</template>
<script>
import sta from "@/api/statis/statis";
export default {
  data() {
    return {
      day: "", //定义初始日期
      btnDisabled:false //按钮是否禁用
    };
  },
  created() {},
  methods: {
    //1.生成统计数据的方法
    create() {
      if(this.day==""||this.day==null){
        alert("请选择日期!")
        window.location.reload();
      }
      sta.createStatisData(this.day).then(response => {
        //提示信息
        this.$message({
          type: "success",
          message: "生成数据图表成功!"
        });
        //跳转页面到show
        this.$router.push({path:'show'})
      });
    }
  }
};
</script>